package com.finanzas.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.finanzas.dao.LdapSocioDao;
import com.finanzas.entity.LdapSocio;

/**
 * Servlet implementation class ValidaDatosServlet
 */
@WebServlet("/ValidaDatosServlet")
public class ValidaDatosServlet extends HttpServlet {
	
	private static final long serialVersionUID = 1L;
	@EJB
	private LdapSocioDao ldapSocioDao;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ValidaDatosServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		PrintWriter out = response.getWriter();
		
		if (true) {
			String usuario = request.getParameter("usuario");
			LdapSocio ldapSocio = new LdapSocio();
			ldapSocio.setUser(usuario);
			Boolean flagLdap = ldapSocioDao.consultarUsuarioLDAP(ldapSocio);
			if (flagLdap) {
				//out.println("El Usuario no esta esta disponible");
			} else {
				out.println("El Usuario esta disponible");
			}
		}
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
